package com.jastar.android.game.lego.brick;

import java.util.Objects;

public class Brick {

    //0xFFFFA0A0,0xFFFFB464,0xFFFFDC64,0xFFA0D278,0xFF78D2D2,0xFF8CB4E6,0xFFC896DC
    private static final int[] COLORS = {0xFFFFA0A0, 0xFFFFDC64, 0xFFA0D278, 0xFF8CB4E6};

    private BrickType type;
    private int color;

    public static Brick getDefault() {
        return new Brick(BrickType.SQUARE, COLORS[0]);
    }

    public Brick(BrickType type, int color) {
        this.type = type;
        this.color = color;
    }

    public Brick clone() {
        return new Brick(this.type, this.color);
    }

    public boolean isLastColor() {
        return Objects.equals(COLORS[COLORS.length - 1], this.color);
    }

    public void nextColor() {
        int index = -1;
        for (int i = 0; i < COLORS.length; i++) {
            if (Objects.equals(COLORS[i], this.color)) index = i;
        }
        this.color = COLORS[(index + 1) % COLORS.length];
    }

    public BrickType getType() {
        return type;
    }

    public void setType(BrickType type) {
        this.type = type;
    }

    public int getColor() {
        return color;
    }

    public void setColor(int color) {
        this.color = color;
    }

}
